#!/bin/bash
# start vm automatically

line=`systemctl status vmware | grep "active (running)"`


case "$1" in 
	node1)
		if [ ! "$line" ]; then
			systemctl start vmware
		fi
		vmplayer /develop/vm/node1/centos7.vmx 1>/dev/null 2>&1 &
		;;
	node2)
		if [ ! "$line" ]; then
                        systemctl start vmware
                fi
                vmplayer /develop/vm/node2/centos7.vmx 1>/dev/null 2>&1 &
                ;;
	node3)
		if [ ! "$line" ]; then
                        systemctl start vmware
                fi
		vmplayer /develop/vm/node3/centos7.vmx 1>/dev/null 2>&1 &
		;;
	halo)
		if [ ! "$line" ]; then
                        systemctl start vmware
                fi
                vmplayer /develop/vm/halo/centos7.vmx 1>/dev/null 2>&1 &
                ;;
        xp)
		if [ ! "$line" ]; then
                        systemctl start vmware
                fi
                vmplayer /develop/vm/xp/WinXP.vmx 1>/dev/null 2>&1 &
                ;;
        win7)
                if [ ! "$line" ]; then
                        systemctl start vmware
                fi
                vmplayer /develop/vm/win7/win7.vmx 1>/dev/null 2>&1 &
                ;;
	bd)
		if [ ! "$line" ]; then
                        systemctl start vmware
                fi
		vmplayer /develop/vm/node1/centos7.vmx 1>/dev/null 2>&1 &
		vmplayer /develop/vm/node2/centos7.vmx 1>/dev/null 2>&1 &
		vmplayer /develop/vm/node3/centos7.vmx 1>/dev/null 2>&1 &
		;;
	-h)
		echo version 1.0
		echo Usage: vm {node1 \| node2 \| node3 \| bd \| halo \| xp \| win7}
		echo Additional options:
		echo "    -h"
		echo "    -v"
		;;
	-v)
		echo vm version: 1.0
		;;
	*)
		echo parameter error! Usage: vm {node1 \| node2 \| node3 \| bd \| halo \| xp \| win7 \| -v \| -h}
		;;
esac

# example below: 
# vmware-networks version: 0.1
# Usage: vmware-networks [--verbose | -v] <option>
# Use exactly one of these commands:
  # --postinstall <component-name>,<old-version>,<new-version>
  # --migrate-network-settings <location of settings file>
  # --start
  # --stop
  # --status

# Additional options:
  # --help | -h
  # --version

